<?php

namespace backend\assets;

use yii\base\InvalidConfigException;
use yii\web\AssetBundle;

/**
 * Main backend application asset bundle.
 */
class AppAsset extends AssetBundle
{
    public $sourcePath = '@app/themes/cza/assets';
    // public $basePath = '@webroot';
    // public $baseUrl = '@web';
    public $css = [
        'css/site.css',
    ];
    public $js = [
        'js/app.js',
        'js/qrcode.min.js',
        // 'js/chart.js-3.2.0/package/dist/chart.min.js',
        // 'js/jquery.multipleInput.min.js',
        // 'js/jquery-sortable.min.js',
    ];
    public $depends = [
        // 'yii\web\YiiAsset',
        // 'yii\bootstrap\BootstrapAsset',
        'dmstr\web\AdminLteAsset',
        'cza\base\assets\AppAsset',
    ];

    public $jsOptions = [
        'position'=>\yii\web\View::POS_HEAD,
    ];

    public function init()
    {
        $this->sourcePath = '@app/themes/' . CZA_BACKEND_THEME . '/assets';
        parent::init();
    }

    public static function register($view)
    {
        self::setupAssetsPublishUrls();  // setup assets publish urls
        try {
            return $view->registerAssetBundle(get_called_class());
        } catch (InvalidConfigException $e) {
            return $e->getMessage();
        }
    }

    public static function setupAssetsPublishUrls()
    {
        // \Yii::$app->czaHelper->setEnvData('AdminlteAssets', \Yii::$app->assetManager->getPublishedUrl('@vendor/almasaeed2010/adminlte/dist'));
    }
}
